from PIL import Image
import os

def convert_webp_to_png(folder):
    for file in os.listdir(folder):
        if not file.lower().endswith('.webp'):
            continue
        path = os.path.join(folder, file)
        img = Image.open(path).convert('RGB')
        new_path = os.path.splitext(path)[0] + '.png'
        img.save(new_path)
        os.remove(path)  # 删除原 WebP 文件

if __name__ == "__main__":
    convert_webp_to_png('/root/data/outputs')